package cn.ithers.blog.dao;

import cn.ithers.blog.domain.EsArticle;
import cn.ithers.blog.pojo.Article;
import org.springframework.data.domain.Example;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * @Author: zhanghuan
 * @date: 2020/10/6 8:30
 * @description:
 */
public interface ArticleDao extends JpaRepository<Article, String>, JpaSpecificationExecutor<Article> {
    Article findOneById(String id);

    @Modifying
    int deleteAllById(String articleId);

    @Modifying
    @Query(nativeQuery = true, value = "UPDATE tb_article SET state = '0' WHERE id = ?")
    int deleteArticleByState(String articleId);

    @Query(nativeQuery = true, value = "select labels from tb_article where id = ?")
    String listArticleLabelById(String articleId);


}
